<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var a = prompt("输入昵称");
        var reg = /^[\w\u4e00-\u9fa5]{6,8}$/;
        if(reg.test(a)){
            alert("昵称正常");
        }else{
            alert("昵称非法");
        }
  </script>
</body>
</html>              